/*
 * @Author: tkp
 * @Date: 2023-01-31 16:35:53
 */
import variables from '@/assets/styles/element-variables.scss'
import Cookies from 'js-cookie'
const state = {
    token: Cookies.get('token'),
    theme: variables.theme,
    isCollapse: window.localStorage.getItem('isCollapse') === 'true' ? true : false,
}
const mutations = {
    SET_TOKEN: (state, data) => {
        state.token = data
        Cookies.set('token', data, { path: '/permission' })
    },
    SET_THEME: (state, data) => {
        state.theme = data
    },
    SET_COLLAPSE: (state, data) => {
        state.isCollapse = data || false
        window.localStorage.setItem('isCollapse', data || false)
    },
}
const actions = {
    changeTheme({ commit }, data) {
        commit('SET_THEME', data)
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions,
}